home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / mus / play / multiplsr.lha / audiodev.asm < prev    next >
Assembly Source File  |  1992-09-14  |  4KB  |  135 lines

  1. * MultiPlayer
  2. * Copyright (C) 1992 Bryan Ford
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. *
  18. * I (the author of MultiPlayer) can be contacted on the Internet at
  19. * "bryan.ford@m.cc.utah.edu".  See "Player.doc" for other addresses.
  20. *
  21. * $Id: audiodev.asm,v 4.1 92/06/21 11:15:10 BAF Exp Locker: BAF $
  22. *
  23.  
  24.  
  25.         include "exec/types.i"
  26.         include "exec/io.i"
  27.         include "exec/funcdef.i"
  28.         include "exec/exec_lib.i"
  29.         include "devices/audio.i"
  30.         include "hardware/custom.i"
  31.         include "hardware/dmabits.i"
  32.         include "player.i"
  33.  
  34.         code    text
  35.  
  36.         xdef    allocaudio,freeaudio
  37.  
  38.         xref    diemes
  39.         xref    _SysBase
  40.  
  41. *** Allocate all the audio channels from the audio.device
  42. allocaudio
  43.         bsr     freeaudio
  44.  
  45.         move.l  a6,-(sp)
  46.         move.l  _SysBase(a4),a6
  47.  
  48.         moveq   #-1,d0                  ; Allocate signal
  49.         jsr     _LVOAllocSignal(a6)
  50.         move.b  d0,sigbit(a4)
  51.         bmi     99$
  52.  
  53.         move.b  d0,port+MP_SIGBIT(a4)   ; Setup MsgPort
  54.         move.b  #NT_MSGPORT,port+LN_TYPE(a4)
  55.         suba.l  a1,a1
  56.         jsr     _LVOFindTask(a6)
  57.         move.l  d0,port+MP_SIGTASK(a4)
  58.         lea     port+MP_MSGLIST(a4),a0
  59.         NEWLIST a0
  60.         lea     port(a4),a0
  61.         move.l  a0,req+MN_REPLYPORT(a4)
  62.  
  63.         lea     req(a4),a1              ; Open audio.device and allocate channels
  64.         lea     audiodevname(a4),a0
  65.         moveq   #0,d0
  66.         moveq   #0,d1
  67.         jsr     _LVOOpenDevice(a6)
  68.         tst.b   d0
  69.         bne     99$
  70.         st.b    alloced(a4)
  71.  
  72.         move.l  (sp)+,a6
  73.         rts
  74.  
  75. 99$     lea     noaudtext(a4),a0
  76.         bra     diemes
  77.  
  78. *** Free the audio.device channels
  79. freeaudio
  80.         move.l  a6,-(sp)
  81.         move.l  _SysBase(a4),a6
  82.  
  83.         tst.b   alloced(a4)
  84.         beq.s   19$
  85.  
  86.         lea     CUSTOM,a0               ; Shut up all sound
  87.         move.w  #DMAF_AUD0!DMAF_AUD1!DMAF_AUD2!DMAF_AUD3,dmacon(a0)
  88.         clr.w   aud0+ac_dat(a0)
  89.         clr.w   aud1+ac_dat(a0)
  90.         clr.w   aud2+ac_dat(a0)
  91.         clr.w   aud3+ac_dat(a0)
  92.  
  93.         clr.b   alloced(a4)             ; Close the audio.device
  94.         lea     req(a4),a1
  95.         jsr     _LVOCloseDevice(a6)
  96. 19$
  97.         moveq   #0,d0                   ; Free signal
  98.         move.b  sigbit(a4),d0
  99.         bmi.s   29$
  100.         jsr     _LVOFreeSignal(a6)
  101.         st.b    sigbit(a4)
  102. 29$
  103.         move.l  (sp)+,a6
  104.         rts
  105.  
  106.         data    __MERGED
  107.  
  108. req:    dc.l    0,0
  109.         dc.b    NT_MESSAGE,127  ;use maximum priority (127)
  110.         dc.l    0,0     ;name, replyport
  111.         dc.w    ioa_SIZEOF      ;length
  112.         dc.l    0       ;io_Device
  113.         dc.l    0       ;io_Unit
  114.         dc.w    0       ;io_Command
  115.         dc.b    0,0     ;io_Flags, io_Error
  116.         dc.w    0       ;ioa_AllocKey
  117.         dc.l    allmask ;ioa_Data
  118.         dc.l    1       ;ioa_Length
  119. 9$
  120.         ds.b    ioa_SIZEOF-(9$-req)
  121.  
  122. noaudtext       dc.b    "Audio hardware in use",0
  123. audiodevname:   dc.b    'audio.device',0
  124.  
  125. sigbit          dc.b    -1
  126.  
  127. allmask         dc.b    $f
  128.  
  129.         bss     __MERGED
  130.  
  131. port    ds.b    MP_SIZE
  132. alloced ds.b    1
  133.  
  134.         end
  135.